var express = require('express');
var router = express.Router();
var userControll = require('../controllerss/userController')
var path = require('path')
var formidable = require('formidable')

router.get('/', function(req, res, next) {
    res.send('页面信息');
  });

  router.get('/rewrite', function(req, res, next) {

    userControll.rewrite(req,res)
  });
  router.get('/getInfos', function(req, res, next) {

  userControll.getInfos(req,res)
});

router.get('/getArticle', function(req, res, next) {
userControll.getArticle(req,res)
});

router.get('/showCollect', function(req, res, next) {
  console.log("开始修改")
userControll.showCollect(req,res)
});

  router.post('/upload',function(req,res,next){

    var form = new formidable.IncomingForm()
    form.uploadDir = path.join(__dirname,'..','public','upload')
    form.keepExtensions = true
    form.parse(req,function(err,fields,files){
      console.log(files.personalPicture.path.slice(45))
      console.log(fields.author)
      var userInfo = {uId:fields.author,uPicture:files.personalPicture.path.slice(45)}
      userControll.rePicture(userInfo,res)
    })  
  });

router.get('/getUserInfo', function(req, res, next) {

    userControll.getUserInfo(req,res)
  });

  router.get('/selectConcern', function(req, res, next) {

    userControll.selectConcern(req,res)
  });
  router.get('/selectConcernNum', function(req, res, next) {

    userControll.selectConcernNum(req,res)
  });

  router.get('/selectConcernNums', function(req, res, next) {

    userControll.selectConcernNums(req,res)
  });
  router.get('/selectConcerned', function(req, res, next) {

    userControll.selectConcerned(req,res)
  });




  module.exports = router;